home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar Extras 3
/
Ex3side1.d64
/
rle in basic
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-28
|
884b
|
50 lines
10 input"input file";f$:input"out file";o$
30 a=49152:b=peek(175)*256+peek(174):c=51200
40 gosub70:b=x:gosub11030
50 print"orig:"b-a:print"out:"c-51200:gosub105:end
70 open2,8,2,f$+",p,r":get#2,a$,a$:x=49152
80 get#2,a$:pokex,asc(a$+chr$(0)):x=x+1:ifst=0then80
90 close2:return
105 open2,8,2,"@0:"+o$+",p,w":print#2,chr$(0)chr$(16);:x=51200
110 print#2,chr$(peek(x));:x=x+1:ifx<=cthen110
120 close2:return
11000 a=peek(252)*256+peek(251)
11010 b=peek(254)*256+peek(253)
11020 c=peek(250)*256+peek(249)
11030 i=a:d=0:e=0
11040 fori=atob-1
11050 n=peek(i)
11060 j=i+1
11070 q=peek(j)
11080 ifq=nthengosub11120
11090 ifq<>nthengosub11220
11100 next
11102 ifdthengosub11270
11104 ifethengosub11340
11106 pokec,0:return
11110 end
11120 ifethengosub11340:rem return
11130 d=d+1:rem duplicate
11140 ifd=127thengosub11160
11150 return
11160 pokec,d+1
11170 c=c+1
11180 pokec,n
11190 c=c+1
11200 d=0
11210 return
11220 ifdthengosub11270:return
11230 e=e+1
11240 ife=1thenf=i
11250 ife<127thenreturn
11260 gosub11320:return
11270 pokec,d+1
11280 c=c+1
11290 pokec,n
11300 c=c+1
11310 d=0:return
11320 pokec,eor128:c=c+1
11330 forj=ftoi:pokec,peek(j):c=c+1:next:e=0:d=0:return
11340 pokec,eor128:c=c+1
11350 forj=ftoi-1:pokec,peek(j):c=c+1:next:e=0:d=0:return